package com.xiaoxin.project.system.service.impl;

import com.xiaoxin.framework.aspectj.lang.enums.DataSourceType;
import com.xiaoxin.framework.datasource.DynamicDataSourceContextHolder;
import com.xiaoxin.project.system.domain.SysOrder;
import com.xiaoxin.project.system.mapper.SysOrderMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;


/**
 * 绑定表测试
 *
 * @author ZhangXX
 * @version 1.0
 * @data 2021/5/18 22:49
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("test6")
public class test6 {
    @Autowired
    private SysOrderMapper sysOrderMapper;

    /**
     * 绑定表测试，会随机找一个库去查询
     */
    @Test
    public void testBroadcastTables1() {
        DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.SHARDING.name());
        SysOrder sysOrder = sysOrderMapper.selectSysOrderDetail(742512113695588352L);
        System.out.println(sysOrder);
        DynamicDataSourceContextHolder.clearDataSourceType();
    }

}
